package utils;

import java.io.Serializable;

public class Point implements Serializable,Comparable<Point> {
	
	private float x;
	private float y;
	
	public Point(){
	}
	
	public Point(float x , float y){
		this.x = x;
		this.y = y;
	}

	public float getX() {
		return x;
	}

	public void setX(float x) {
		this.x = x;
	}

	public float getY() {
		return y;
	}

	public void setY(float y) {
		this.y = y;
	}
	
	public String toString(){
		return "<point x=\""+this.x+"\" y=\""+this.y+"\"/>";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + Float.floatToIntBits(x);
		result = prime * result + Float.floatToIntBits(y);
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Point other = (Point) obj;
		if (x != (other.x))
			return false;
		if ((y) != (other.y))
			return false;
		return true;
	}

	@Override
	public int compareTo(Point p) {
		if (x < p.x)
			//p est a droite de this
			return -1;
		else if (x>p.x)
			//p est a gauche de this
			return 1;
		else if (y < p.y)
			//p est en haut de this
			return -1;
		else if (y>p.y)
			//p est en dessous de this
			return 1;
		else 
			return 0;
	}
	
	
}
